package com.moli.iov.admin.websocket.service;

import com.moli.iov.rest.RestResponse;

/**
 * @ClassName AbstractWebSocketSingleExecuteService
 * @Description TODO
 * @Author 李伟松
 * @CreateDate 2019-03-12 下午 2:33
 * @UpdateDate 2019-03-12 下午 2:33
 * @Version 1.0
 */
public abstract class AbstractWebSocketSingleExecuteService<T> implements WebSocketSingleExecuteService{


    public abstract T buildParam(String string) throws Exception;

    public abstract RestResponse exec(T t);

    @Override
    public final RestResponse execute(String json) {
        try {
            T t = buildParam(json);
            return exec(t);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return RestResponse.success();
    }
}
